package com.rc.saas.mini.service.invoice;

import com.google.gson.Gson;
import com.rc.saas.mini.common.base.TResponse;
import com.rc.saas.mini.mapper.elec.ElecStationMapper;
import com.rc.saas.mini.mapper.invoice.InvoiceMapper;
import com.rc.saas.mini.mapper.invoice.InvoiceOrderMapper;
import com.rc.saas.mini.mapper.order.OrderInfoMapper;
import com.rc.saas.mini.model.elec.ElecStation;
import com.rc.saas.mini.model.elec.ElecStationExample;
import com.rc.saas.mini.model.invoice.Invoice;
import com.rc.saas.mini.model.invoice.InvoiceExample;
import com.rc.saas.mini.model.invoice.InvoiceOrder;
import com.rc.saas.mini.model.invoice.InvoiceOrderExample;
import com.rc.saas.mini.model.order.OrderInfo;
import com.rc.saas.mini.model.order.OrderInfoExample;
import com.rc.saas.mini.vo.invoice.InvoiceApplyVo;
import io.swagger.models.auth.In;
import org.apache.http.HttpResponse;
import org.apache.http.client.ResponseHandler;
import org.apache.http.client.fluent.Request;
import org.apache.http.entity.StringEntity;
import org.apache.http.util.EntityUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.jar.JarEntry;
import java.util.stream.Collectors;

/**
 * @author wangzhengwei
 * @create 2021/4/28
 */
@Service
public class InvoiceServiceImpl implements InvoiceService {
    private static Logger logger = LogManager.getLogger(InvoiceServiceImpl.class);

    @Autowired
    private InvoiceMapper invoiceMapper;

    @Override
    public InvoiceMapper getMapper() {
        return invoiceMapper;
    }

    @Override
    public Invoice selectInvoiceByApplyId(Long invoiceApplyId) {
        InvoiceExample example = new InvoiceExample();
        example.createCriteria().andInvoiceApplyIdEqualTo(invoiceApplyId);
        return this.selectByExample(example).stream().findFirst().orElseGet(() -> null);
    }

    @Override
    public List<Invoice> listByCondition(Invoice invoice) {
        return invoiceMapper.listByCondition(invoice);
    }
}
